package com.ruoyi.web.controller.pinko;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.PinkoCurrencyfields;
import com.ruoyi.system.service.IPinkoCurrencyfieldsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 币种自定义字段信息Controller
 * 
 * @author ruoyi
 * @date 2024-06-07
 */
@RestController
@RequestMapping("/system/currencyfields")
public class PinkoCurrencyfieldsController extends BaseController
{
    @Autowired
    private IPinkoCurrencyfieldsService pinkoCurrencyfieldsService;

    /**
     * 查询币种自定义字段信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:currencyfields:list')")
    @GetMapping("/list")
    public TableDataInfo list(PinkoCurrencyfields pinkoCurrencyfields)
    {
        startPage();
        List<PinkoCurrencyfields> list = pinkoCurrencyfieldsService.selectPinkoCurrencyfieldsList(pinkoCurrencyfields);
        return getDataTable(list);
    }

    /**
     * 导出币种自定义字段信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:currencyfields:export')")
    @Log(title = "币种自定义字段信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PinkoCurrencyfields pinkoCurrencyfields)
    {
        List<PinkoCurrencyfields> list = pinkoCurrencyfieldsService.selectPinkoCurrencyfieldsList(pinkoCurrencyfields);
        ExcelUtil<PinkoCurrencyfields> util = new ExcelUtil<PinkoCurrencyfields>(PinkoCurrencyfields.class);
        util.exportExcel(response, list, "币种自定义字段信息数据");
    }

    /**
     * 获取币种自定义字段信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:currencyfields:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(pinkoCurrencyfieldsService.selectPinkoCurrencyfieldsById(id));
    }

    /**
     * 新增币种自定义字段信息
     */
    @PreAuthorize("@ss.hasPermi('system:currencyfields:add')")
    @Log(title = "币种自定义字段信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PinkoCurrencyfields pinkoCurrencyfields)
    {
        return toAjax(pinkoCurrencyfieldsService.insertPinkoCurrencyfields(pinkoCurrencyfields));
    }
    @PreAuthorize("@ss.hasPermi('system:currencyfields:add')")
    @Log(title = "币种自定义字段信息", businessType = BusinessType.INSERT)
    @PostMapping("SaveList")
    public AjaxResult save(@RequestBody List<PinkoCurrencyfields> CurrencyfieldsList)
    {
        int result=0;
        for (int i = 0; i < CurrencyfieldsList.size(); i++) {
            PinkoCurrencyfields pinkoCurrencyfields=CurrencyfieldsList.get(i);
            result=result+pinkoCurrencyfieldsService.insertPinkoCurrencyfields(pinkoCurrencyfields);
        }
        return toAjax(result);
    }
    /**
     * 修改币种自定义字段信息
     */
    @PreAuthorize("@ss.hasPermi('system:currencyfields:edit')")
    @Log(title = "币种自定义字段信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PinkoCurrencyfields pinkoCurrencyfields)
    {
        return toAjax(pinkoCurrencyfieldsService.updatePinkoCurrencyfields(pinkoCurrencyfields));
    }

    /**
     * 删除币种自定义字段信息
     */
    @PreAuthorize("@ss.hasPermi('system:currencyfields:remove')")
    @Log(title = "币种自定义字段信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(pinkoCurrencyfieldsService.deletePinkoCurrencyfieldsByIds(ids));
    }
}
